<%@page import="cn.jhc.dao.ActDAO"%>
<%@page import="cn.jhc.bean.HfmsgBean"%>
<%@page import="cn.jhc.bean.UserBean"%>
<%@page import="cn.jhc.bean.AllHfmsgBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="cn.jhc.bean.UserBean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/taolunqu.css"></link>
<title>留言板</title>
</head>
<body>
	<%
		int CurrentPage = 1; //初始值,第一页
		int intPageCount; //全部的也数
		if (request.getParameter("page") != null) //判断传过来的数据
			CurrentPage = Integer.parseInt(request.getParameter("page")); //装换为整形
		if (CurrentPage < 1) //使初始值不小于一，始终是第一页
			CurrentPage = 1;
	%>
	<div id="wrapper">
		<div id="wrapperdown">
			<%
				String id = request.getParameter("id");
				int Id = Integer.parseInt(id);
				HfmsgBean m = new HfmsgBean();
				ActDAO dao = new ActDAO();
				dao.setCon(ConnectionFactory.getConnection());
				m = dao.getoneMessages(Id);
				request.setAttribute("title", m);
			%>
			<%
				HfmsgBean t = new HfmsgBean();
				ActDAO dao3 = new ActDAO();
				dao3.setCon(ConnectionFactory.getConnection());
				t = dao3.getonetopMessages(Id);
				request.setAttribute("top", t);
			%>
			<%
				dao.setCon(ConnectionFactory.getConnection());
				ArrayList<AllHfmsgBean> h = new ArrayList<AllHfmsgBean>();
				h = dao.getHFMessages(Id, CurrentPage);
				request.setAttribute("liuyan", h);
			%>
			<%
				ActDAO dao2 = new ActDAO();
				dao2.setCon(ConnectionFactory.getConnection());
				intPageCount = dao2.getHfCount(Id);
				if (intPageCount == 0) {
					CurrentPage = 1;
					intPageCount = 1;
				} else {
					if (CurrentPage > intPageCount)
						CurrentPage = intPageCount;
				}
			%>
			<jsp:include page="./header.jsp"></jsp:include>
			<table width="1000">
				<tr>
					<td width="400" height="200" rowspan="2" valign="top"><div
							align="left">昵称：${requestScope.title.displayname}${requestScope.top.displayname}</div></td>
					<td width="600" valign="top"><div align="left">标题：${requestScope.title.title}${requestScope.top.title}</div></td>
				</tr>
				<tr>
					<td valign="top"><div align="left">内容：${requestScope.title.content}${requestScope.top.content}</div></td>
				</tr>
				<c:forEach var="liuyan" items="${requestScope.liuyan}">
					<tr>
						<td height="200" valign="top"><div align="left">昵称：${liuyan.displayname}</div></td>
						<td valign="top"><div align="left">回复：${liuyan.content}</div></td>
					</tr>
				</c:forEach>
			</table>
			<div align="right">
				<a>第<%=CurrentPage%>页 共<%=intPageCount%>页
				</a> <a
					href="showActmessages.jsp?page=<%=1%>&id=${requestScope.title.id}">首页</a>
				<%
					if (CurrentPage > 1) {
				%>
				<a
					href="showActmessages.jsp?page=<%=CurrentPage-1%>&id=${requestScope.title.id}">上一页</a>
				<%
					} else {
				%>
				上一页
				<%
					}
				%>
				<%
					if (CurrentPage >= intPageCount) {
				%>
				下一页
				<%
					} else {
				%>
				<a
					href="showActmessages.jsp?page=<%=CurrentPage+1%>&id=${requestScope.title.id}">下一页</a>
				<%
					}
				%>
				<a
					href="showActmessages.jsp?page=<%=intPageCount%>&id=${requestScope.title.id}">末页</a>
			</div>
			<div id="submit">
				<form method="post"
					action="./addHfActmessage.do?titleid=${requestScope.title.id}&getb=/showActmessages.jsp&id=${requestScope.title.id}">
					<p>
						<label for="content">内容</label>
						<textarea rows="7" cols="60" name="content"></textarea>
					</p>
					<p>
						<input type="hidden" name="getb"
							value="/showActmessages.jsp?titleid=${requestScope.title.id}">
						<input type="submit" value="提交"></input> <input type="reset" />
					</p>
				</form>
			</div>
		</div>
	</div>
</body>
</html>